#-*- coding: utf-8 -*-

def check_requires(svclst,reqstr,sep = ";", switch_sep = "||", comp = "and", errors = []):
    if comp == "and":
        res = True
    else:
        res = False
    reqstr = reqstr.split(sep)
    #print reqstr
    for s in reqstr:
        if s:
            s = s.strip()
            if s.find(switch_sep) >= 0:
                if comp == "and":
                    res = check_requires(svclst, s, switch_sep, sep, "or")
                else:
                    res = check_requires(svclst, s, switch_sep, sep, "and")
            else:
                if comp == "and":
                    if s not in svclst.keys():
                        res = False
                        errors.append(s)
                else:
                    if s in svclst:
                        res = True
        if not res and comp == "or":
            errors.append(s)
    return res
